library IEEE;
use IEEE.std_logic_1164.all;
use work.state_pkg.all;


entity encoder_substates is
  port (    
    track_cont : in std_logic;
    search_cont : in std_logic;
    cross_cont : in std_logic;
    map_cont : in std_logic;
    
    track_dir : in direction_type;
    search_dir : in direction_type;
    cross_dir : in direction_type;
    map_dir : in direction_type;
    
    track_dbm : in string(2 downto 1);
    search_dbm : in string(2 downto 1);
    cross_dbm : in string(2 downto 1);
    map_dbm : in string(2 downto 1);
    
    state : in std_logic_vector(1 downto 0);
    
    
    continu : out std_logic;
    direction : out direction_type;
    dbm : out string(2 downto 1)
    
  );
end entity encoder_substates;


architecture behavioural of encoder_substates is
  
begin
  WITH state SELECT
    continu <= track_cont WHEN "01",
               search_cont WHEN "10",
               cross_cont WHEN "11",
               map_cont WHEN "00",
               'X' WHEN OTHERS;
  WITH state SELECT
    direction <= track_dir WHEN "01",
                 search_dir WHEN "10",
                 cross_dir WHEN "11",
                 map_dir WHEN "00",
                 STOP WHEN OTHERS;
  WITH state SELECT
    dbm <= track_dbm WHEN "01",
           search_dbm WHEN "10",
           cross_dbm WHEN "11",
           map_dbm WHEN "00",
           "  " WHEN OTHERS;
end architecture behavioural;
